﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Web.Mvc;

namespace HashFoo.Rest.Server
{
    /// <summary>
    /// Defines an action result of an <see cref="IServiceHandler{TRequest}"/>.  This is a special <see cref="ContentResult"/>.
    /// </summary>
    /// <remarks>
    /// The <c>ResourceActionResult</c> flags that a result should be handled by the <see cref="ResourceSerializerFilter"/>.  The filter
    /// will handle setting the content, content type, etc.  The creater just needs to supply the <see cref="Resource"/>.
    /// </remarks>
    public class ResourceActionResult : ContentResult
    {
        /// <summary>
        /// The resource that is the result of the <see cref="IServiceHandler{TRequest}"/>
        /// </summary>
        public object Resource { get; private set; }

        /// <summary>
        /// Creates a new <see cref="ResourceActionResult"/>
        /// </summary>
        /// <param name="resource">The resource to return.  It will be serialized by the <see cref="ResourceSerializerFilter"/></param>
        public ResourceActionResult(object resource)
        {
            Resource = resource;
        }

        /// <summary>
        /// Creates an empty resource result (the <see cref="Resource"/> will be null).
        /// </summary>
        public ResourceActionResult( )
        {
            
        }
    }
}